import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/position/knowledge/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getKnowledgeList = (current, size, params) => {
  return request({
    url: '/position/knowledge/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const getDetail = (id) => {
  return request({
    url: '/position/knowledge/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/position/knowledge/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/position/knowledge/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/position/knowledge/submit',
    method: 'post',
    data: row
  })
}

export const saveKnowledge = (data) => {
  return request({
    url: '/position/knowledge/save',
    method: 'post',
    data
  })
}

export const updateKnowledge = (data) => {
  return request({
    url: '/position/knowledge/update',
    method: 'post',
    data
  })
}

export const removeKnowledge = (ids) => {
  return request({
    url: '/position/knowledge/remove',
    method: 'post',
    params: {
      ids
    }
  })
}

export const createCourseware = (data) => {
  return request({
    url: '/position/courseware/save',
    method: 'post',
    data
  })
}

export const updateCourseware = (data) => {
  return request({
    url: '/position/courseware/update',
    method: 'post',
    data
  })
}

export const deleteCourseware = (ids, knowledgeId) => {
  return request({
    url: '/position/courseware/remove',
    method: 'post',
    params: {
      ids,
      knowledgeId
    }
  })
}

export const publishCourseware = (params) => {
  return request({
    url: '/position/knowledge/publish',
    method: 'post',
    params
  })
}

export const unPublishCourseware = (params) => {
  return request({
    url: '/position/knowledge/unPublish',
    method: 'post',
    params
  })
}

export const getCoursewareLists = (current, size, params) => {
  return request({
    url: '/position/courseware/list',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

